<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/28
 * Time: 13:58
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\PartnerMessageLogic;
use App\Http\Traits\PartnerMessageTrait;
use App\Http\Controllers\BaseController;
class PartnerMessageController extends BaseController
{
    use PartnerMessageTrait;

    /**
     * @SWG\Post(
     *     path="/partnerMessage/create",
     *     tags={"PartnerMessage"},
     *     description="创建合作者留言",
     *     operationId="createPartnerMessage",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="key",
     *         in="query",
     *         description="合作者key",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="photo_list_str",
     *         in="query",
     *         description="图片列表字符串",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="content",
     *         in="query",
     *         description="留言内容",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createPartnerMessage()
    {
        $photo_list_str = $this->photo_list_str;
        $content = $this->content;
        $key = $this->key;
        $loginSession = $this->loginSession;
        $data = [
            'photo_list_str' => $photo_list_str,
            'content' => $content,
            'key' => $key,
            'loginSession' => $loginSession
        ];
        $response = PartnerMessageLogic::createPartnerMessage($data);
        if ($response->code){
            return self::response($response->code, $response->message);
        }
        return self::response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/partnerMessage/getList",
     *     tags={"PartnerMessage"},
     *     description="获取留言列表",
     *     operationId="getPartnerMessageList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="key",
     *         in="query",
     *         description="合作者key",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getPartnerMessageList()
    {
        $key = $this->key;
        $loginSession = $this->loginSession;
        $data = [
            'key' => $key,
            'loginSession' => $loginSession
        ];
        $response = PartnerMessageLogic::getPartnerMessageList($data);
        if ($response->code){
            return self::response($response->code, $response->message);
        }
        return self::response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/partnerMessage/getDetail",
     *     tags={"PartnerMessage"},
     *     description="获取合作者留言详情",
     *     operationId="getPartnerMessageDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="partner_message_id",
     *         in="query",
     *         description="合作者留言ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getPartnerMessageDetail()
    {
        $partner_message_id = $this->partner_message_id;
        $data = [
            'partner_message_id' => $partner_message_id
        ];
        $response = PartnerMessageLogic::getPartnerMessageDetail($data);
        if ($response->code){
            return self::response($response->code, $response->message);
        }
        return self::response($response->code, $response->message, $response->data);
    }
}